# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=avahi-ui
pkgver=0.8
pkgrel=7
pkgdesc="Gtk user interface library for Avahi"
url="https://www.avahi.org/"
arch="all"
license="LGPL-2.1-or-later"
depends_dev="gdbm-dev"
makedepends="$depends_dev py3-gobject3-dev py3-dbus-dev libevent-dev
	gobject-introspection-dev expat-dev libdaemon-dev glib-dev dbus-dev
	libcap-dev python3-dev autoconf automake libtool avahi-dev gtk+3.0-dev"
subpackages="$pkgname-dev $pkgname-tools $pkgname-gtk3"
source="https://www.avahi.org/download/avahi-$pkgver.tar.gz
	system-avahi.patch
	gnome-nettool.png"
_subdirs="avahi-ui avahi-python"
builddir="$srcdir"/avahi-$pkgver

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	# we dont build autoipd since dhcpcd does same job
	LDFLAGS="$LDFLAGS -lintl" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--disable-autoipd \
		--disable-qt3 \
		--disable-qt4 \
		--disable-qt5 \
		--disable-gtk \
		--enable-gtk3 \
		--disable-mono \
		--disable-monodoc \
		--disable-doxygen-doc \
		--disable-xmltoman \
		--disable-compat-libdns_sd \
		--disable-compat-howl \
		--with-distro="gentoo" \
		--with-systemdsystemunitdir=/lib/systemd/system \
		--disable-python \
		--disable-static \
		--enable-shared
	for i in $_subdirs; do
		(cd $i && make)
	done
}

check() {
	make check
}

package() {
	make install-pkgconfigDATA DESTDIR="$pkgdir" \
		pkgconfig_DATA="avahi-ui-gtk3.pc"
	mkdir -p "$pkgdir"/usr/bin
	for i in avahi-ui avahi-python; do
		make -C $i DESTDIR="$pkgdir" install
	done
}

tools() {
	depends=""
	pkgdesc="UI tools for mDNS browsing"
	mkdir -p "$subpkgdir"/usr/bin
	cd "$pkgdir"/usr/bin
	mv b* "$subpkgdir"/usr/bin/
	install -D -m 644 "$srcdir"/gnome-nettool.png \
		"$subpkgdir"/usr/share/pixmaps/gnome-nettool.png

	# This depends on py-gtk
	rm -f "$subpkgdir"/usr/bin/avahi-bookmarks
}

gtk3() {
	pkgdesc="Gtk3 user interface library for Avahi"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libavahi-ui-gtk3.so.* \
		"$subpkgdir"/usr/lib/
}

sha512sums="
c6ba76feb6e92f70289f94b3bf12e5f5c66c11628ce0aeb3cadfb72c13a5d1a9bd56d71bdf3072627a76cd103b9b056d9131aa49ffe11fa334c24ab3b596c7de  avahi-0.8.tar.gz
99723e66889601044ac5ca919e79aa328083cb377bb3d270f3e8d2baee27505f967949f72faa0424756e5f18b1359fd7f7fb30636861d47455ff7b92ed48bcfa  system-avahi.patch
261183cd4659b2c2fd4df53c109f310f62c726bbd590d158a270a0fe461167c6409460f811c5188435004a4da79b843505921465018a2e57c40c4bac84b3c096  gnome-nettool.png
"
